Security News
Python Overtakes JavaScript as Top Programming Language on GitHub
Python becomes GitHub's top language in 2024, driven by AI and data science projects, while AI-powered security tools are gaining adoption.
@babel/plugin-transform-react-display-name
Advanced tools
Add displayName to React.createClass calls
The @babel/plugin-transform-react-display-name npm package is a Babel plugin that adds the displayName property to React components for use in debugging messages and dev tools. It helps to identify components in the React DevTools by providing a readable name, which is particularly useful for anonymous components.
Automatic displayName assignment for React components
This feature automatically assigns a displayName to React components based on their name. This is useful for debugging purposes, as it allows you to see the component's name in the React DevTools.
class MyComponent extends React.Component {}
// Transformed code with displayName:
// MyComponent.displayName = 'MyComponent';
displayName assignment for functional components
Similar to class components, this feature assigns a displayName to functional components, making them easier to identify in the React DevTools.
const MyComponent = () => <div />;
// Transformed code with displayName:
// MyComponent.displayName = 'MyComponent';
displayName assignment for components created with React.createClass
For components created using React.createClass, this plugin also adds a displayName property, which is useful for projects that have not yet migrated to ES6 classes or functional components.
const MyComponent = React.createClass({
render: function() { return <div />; }
});
// Transformed code with displayName:
// MyComponent.displayName = 'MyComponent';
This package is similar to @babel/plugin-transform-react-display-name as it also adds a displayName to React components. However, it is a standalone Babel plugin that might not be as actively maintained or integrated into the Babel ecosystem as the official Babel plugin.
This package provides a utility function to help manually assign a displayName to a React component. It is not a Babel plugin and requires manual usage within the code, unlike the automatic transformation provided by @babel/plugin-transform-react-display-name.
Add displayName to React.createClass calls
See our website @babel/plugin-transform-react-display-name for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-react-display-name
or using yarn:
yarn add @babel/plugin-transform-react-display-name --dev
v7.25.9 (2024-10-22)
babel-parser
, babel-template
, babel-types
syntacticPlaceholders
mode (@liuxingbaoyu)babel-helper-compilation-targets
, babel-preset-env
ClassAccessorProperty
to prevent the no-undef
rule (@victorenator)babel-parser
, babel-types
VISITOR_KEYS
etc. faster to access (@liuxingbaoyu)FAQs
Add displayName to React.createClass calls
The npm package @babel/plugin-transform-react-display-name receives a total of 16,478,440 weekly downloads. As such, @babel/plugin-transform-react-display-name popularity was classified as popular.
We found that @babel/plugin-transform-react-display-name demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Python becomes GitHub's top language in 2024, driven by AI and data science projects, while AI-powered security tools are gaining adoption.
Security News
Dutch National Police and FBI dismantle Redline and Meta infostealer malware-as-a-service operations in Operation Magnus, seizing servers and source code.
Research
Security News
Socket is tracking a new trend where malicious actors are now exploiting the popularity of LLM research to spread malware through seemingly useful open source packages.